|
| 1 | +# @carbon/styles |
| 2 | + |
| 3 | +> Styles for the Carbon Design System |
| 4 | +
|
| 5 | +## Getting started |
| 6 | + |
| 7 | +To install `@carbon/styles` in your project, you will need to run the following |
| 8 | +command using [npm](https://www.npmjs.com/): |
| 9 | + |
| 10 | +```bash |
| 11 | +npm install -S @carbon/styles |
| 12 | +``` |
| 13 | + |
| 14 | +If you prefer [Yarn](https://yarnpkg.com/en/), use the following command |
| 15 | +instead: |
| 16 | + |
| 17 | +```bash |
| 18 | +yarn add @carbon/styles |
| 19 | +``` |
| 20 | + |
| 21 | +## Usage |
| 22 | + |
| 23 | +### Sass entrypoints |
| 24 | + |
| 25 | +| Entrypoint | Description | |
| 26 | +| ---------------------------- | ------------------------------------------------------------------------------------------------------------ | |
| 27 | +| `index.scss` | Entrypoint that brings in all of the CSS for the Carbon Design System | |
| 28 | +| `scss/_breakpoint.scss` | Use helpers to easily create breakpoints in your product that align to the 16 column grid | |
| 29 | +| `scss/_colors.scss` | Provides access to colors from the IBM Design Language | |
| 30 | +| `scss/_config.scss` | Allows you to configure various behaviors of Carbon | |
| 31 | +| `scss/_feature-flags.scss` | Enable or disable various feature flags to try out experiments within Carbon | |
| 32 | +| `scss/_grid.scss` | Provides access to grid mixins and helpers for working with the 16 column grid | |
| 33 | +| `scss/_motion.scss` | Provides access to motion easing curves and durations from the IBM Design Language | |
| 34 | +| `scss/_reset.scss` | Brings in a CSS reset to enable consistent styles across browsers | |
| 35 | +| `scss/_themes.scss` | Provides access to the default themes used with Carbon | |
| 36 | +| `scss/_theme.scss` | Provides access to the current theme and theme helpers to use in your project | |
| 37 | +| `scss/_type.scss` | Provides access to type tokens configured for use with IBM Plex | |
| 38 | +| `scss/components/*` | Bring in a single component, or several that you need for your project. Great for optimizing CSS bundle size | |
| 39 | +| `scss/components/index.scss` | Bring in all component styles | |
| 40 | + |
| 41 | +### Optimizing CSS bundle size |
| 42 | + |
| 43 | +When you bring in `@carbon/styles` directly, it will include all of the styles |
| 44 | +available for the Carbon Design System. If you would like to bring in only the |
| 45 | +styles that you use, then we recommend structuring your imports in the following |
| 46 | +way: |
| 47 | + |
| 48 | +```scss |
| 49 | +// Bring in top-level / global styles |
| 50 | +@use '@carbon/styles/reset'; |
| 51 | + |
| 52 | +// Bring in each component that you use |
| 53 | +@use '@carbon/styles/scss/components/<component>'; |
| 54 | +``` |
| 55 | + |
| 56 | +For example, if your project is only using the Accordion and Breadcrumb |
| 57 | +components then you would do the following: |
| 58 | + |
| 59 | +```scss |
| 60 | +@use '@carbon/styles/reset'; |
| 61 | +@use '@carbon/styles/scss/components/accordion'; |
| 62 | +@use '@carbon/styles/scss/components/breadcrumb'; |
| 63 | +``` |
| 64 | + |
| 65 | +## 🙌 Contributing |
| 66 | + |
| 67 | +We're always looking for contributors to help us fix bugs, build new features, |
| 68 | +or help us improve the project documentation. If you're interested, definitely |
| 69 | +check out our [Contributing Guide](/.github/CONTRIBUTING.md)! 👀 |
| 70 | + |
| 71 | +## 📝 License |
| 72 | + |
| 73 | +Licensed under the [Apache 2.0 License](/LICENSE). |
0 commit comments