Snippet
Learn how to boost development efficiency by providing frequently used UI patterns as snippets.
Overview
Snippet is a solution to optimize developer experience (DX) while adopting Compound Components as the default. It's a pattern that helps you use complex compound components easily.
Compound Components
In the traditional closed component approach, component customization was limited. For example, with a closed component like:
The internal implementation was hidden, making it difficult to meet customization requirements like:
- How to add styles to the label
- How to change the checkbox icon
- How to pass refs to div and input separately
To solve these issues, we adopted the compound components pattern:
Why Snippet matters
Compound components provide excellent flexibility, but writing such detailed implementations each time can be tedious. To solve this trade-off between flexibility and DX, the Snippet concept was introduced.
Using Snippet
Run CLI
You can add snippets of required components to your project using the following command:
CLI Commands
Learn more about CLI commands.
Using generated snippets
After running CLI, snippets are created in the seed-design/ui/* directory. For example: