Options using union
Table of Contents
Options using union of literal
Union of Literals
When you create a union of literal values, Val Studio automatically displays it as a dropdown in the editor. This is perfect for fields with a fixed set of options.
Basic Dropdown
Create a dropdown by using `s.union()` with multiple `s.literal()` values:
Type Safety
Literal unions provide complete type safety. TypeScript knows exactly which values are valid:
Common Use Cases
Dropdowns are ideal for:
Button variants and sizes
Color themes or styles
Alignment options (left, center, right)
Status values (draft, published, archived)
Priority levels (low, medium, high)
Example: Card Component
Here's a complete example of a card component with multiple dropdown options: