|
1 | | -# Clay.css |
| 1 | +# clay.css |
2 | 2 |
|
3 | | -Extensible and configurable micro CSS class and SASS mixin for adding claymorphism styles to your components. |
| 3 | +Extensible and configurable micro CSS util class and SASS mixin for adding claymorphism styles to your components. |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +## About |
| 8 | + |
| 9 | +Claymorphism is a fresh new concept. The name was coined by [Michał Malewicz](https://hype4.academy/articles/design/claymorphism-in-user-interfaces) and the designers are excited to explore the possibilities of this approach to UI design. |
| 10 | + |
| 11 | +It features inflated fluffy 3D elements which look charming and introduce a much more vibrant look compared to the usual flat designs. |
| 12 | + |
| 13 | +What sets claymorphism apart from neumorphism is that it floats above the background instead of being connected to it, eliminating accessibility issues and design restrictions of the latter. |
| 14 | + |
| 15 | +## Installation |
| 16 | +### CDN |
| 17 | + |
| 18 | +``` |
| 19 | +<link |
| 20 | + rel="stylesheet" |
| 21 | + href="https://unpkg.com/claymorphism-css/dist/clay.css" |
| 22 | +/> |
| 23 | +``` |
| 24 | + |
| 25 | +### NPM |
| 26 | + |
| 27 | +``` |
| 28 | +npm i claymorphism-css |
| 29 | +``` |
| 30 | + |
| 31 | +``` |
| 32 | +yarn add claymorphism-css |
| 33 | +``` |
| 34 | + |
| 35 | +### Manual |
| 36 | + |
| 37 | +Download and add the `dist/clay.css` or `dist/clay.scss` manually. |
| 38 | + |
| 39 | +## Usage |
| 40 | + |
| 41 | +This is a minimal, single class CSS util that applies only basic claymorphism styles: |
| 42 | +* Background |
| 43 | +* Border radius |
| 44 | +* One outset shadow |
| 45 | +* Two inset shadows |
| 46 | + |
| 47 | +```html |
| 48 | +<div class="clay"> |
| 49 | + Fluffy ipsum dolor sit amet consectetur... |
| 50 | +</div> |
| 51 | +``` |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +This CSS class allows you to easily change the claymorphic styles via CSS properies. These changes and additional styles should be applied with the extending class. |
| 56 | + |
| 57 | +```html |
| 58 | +<div class="clay card"> |
| 59 | + Fluffy ipsum dolor sit amet consectetur... |
| 60 | +</div> |
| 61 | +``` |
| 62 | + |
| 63 | +```css |
| 64 | +.card{ |
| 65 | + /* Modify clay.css properties */ |
| 66 | + --clay-background: #f76d6d; |
| 67 | + --clay-border-radius: 48px; |
| 68 | + |
| 69 | + /* Extended styles */ |
| 70 | + color: #f1f1f1; |
| 71 | + padding: 48px; |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +## Options (CSS Variables) |
| 79 | + |
| 80 | +``` |
| 81 | +--clay-background |
| 82 | +--clay-border-radius |
| 83 | +--clay-shadow-outset |
| 84 | +--clay-shadow-inset-primary |
| 85 | +--clay-shadow-inset-secondary |
| 86 | +``` |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | +## SASS Mixin |
| 91 | + |
| 92 | +SASS mixin allows you more flexibility in applying claymorphism styles to your components. For example, this way you can easily add styles to pseudo-elements or pseudo-selectors or use the mixin in other SASS mixins or functions. |
| 93 | + |
| 94 | +``` |
| 95 | +@import "claymorphism-css/dist/clay.scss"; |
| 96 | +
|
| 97 | +@import @include clay( |
| 98 | + $background: [value], |
| 99 | + $border-radius: [value], |
| 100 | + $shadow-outset: [value], |
| 101 | + $shadow-inset-primary: [value], |
| 102 | + $shadow-inset-secondary: [value] |
| 103 | +); |
| 104 | +``` |
| 105 | + |
| 106 | + |
| 107 | +## FAQ |
| 108 | + |
| 109 | +### How do I apply claymorphism styles to pseudo-elements or pseudo-selectors? |
| 110 | + |
| 111 | +If you are using SASS, you can easily do it with the mixin. See the example above. |
| 112 | + |
| 113 | +If you are using vanilla CSS and a util class, you cannot apply it to pseudo-elements and pseudo-selectors. |
| 114 | + |
| 115 | +You'll have to apply the following styles manually. Check out the default values provided by the `clay` class. |
| 116 | + |
| 117 | +```css |
| 118 | + background: [value]; |
| 119 | + border-radius: [value]; |
| 120 | + box-shadow: [value]; |
| 121 | +``` |
| 122 | + |
| 123 | + |
| 124 | +### Why not build the entire framework / design system? |
| 125 | + |
| 126 | +This is a relatively new and unexplored concept, so I didn't want to build an entire design system or a CSS framework with styled buttons. inputs, nav, cards and other elements, etc. and create a framework with accessibility issues that is also massive and difficult to maintain and use. |
| 127 | + |
| 128 | +I wanted to leave it unopinionated and simple, so its easily customizable and can be sprinkled throughout your project. |
| 129 | + |
| 130 | +I used it while building the [Demo page](https://codeadrian.github.io/clay.css/) and it was really fun, useful and intuitive. CSS variables are easy to memorize and easily customizable. |
| 131 | + |
| 132 | +## Sponsors |
| 133 | + |
| 134 | +If you enjoy using clay.css, please consider supporting the development of the project. Your name and link will appear here. |
| 135 | + |
| 136 | +[Become a sponsor!](https://www.buymeacoffee.com/ubnZ8GgDJ/e/52580) |
0 commit comments