Playground
Size, tone and disabled variants on the base token vocabulary.Loading compiler…
TypeScript · React
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { stylesheet, type Variants } from './system.ts' export type ButtonVariants = { size: 'small' | 'medium' | 'large' tone: 'action' | 'secondary' | 'danger' disabled: boolean } // The base vocabulary: spacing steps, semantic colours and typography. export const buttonStyles = stylesheet({ Root: { $kind: 'pressable', display: 'inline-flex', alignItems: 'center', gap: 2, paddingX: 4, paddingY: 2, borderRadius: 'large', bgColor: 'action', textColor: 'on_action', typography: 'label-medium', shadow: 'small', cursor: 'pointer', ':hover': { opacity: 0.88, shadow: 'medium' }, }, Badge: { $kind: 'text', paddingX: 2, borderRadius: 'full', bgColor: 'default', textColor: 'default', typography: 'label-small', }, }).variants( ($: Variants<ButtonVariants>) => ({ [$.size('small')]: { Root: { paddingX: 3, paddingY: 1, typography: 'label-small' }, }, [$.size('large')]: { Root: { paddingX: 6, paddingY: 3, typography: 'label-large' }, }, [$.tone('secondary')]: { Root: { bgColor: 'action_secondary', textColor: 'on_action_secondary' }, }, [$.tone('danger')]: { Root: { bgColor: 'destructive', textColor: 'on_destructive' }, }, [$.disabled(true)]: { Root: { opacity: 0.45, cursor: 'not-allowed', shadow: 'none' }, }, }), { defaults: { size: 'medium', tone: 'action', disabled: false } }, )
Tab indents · Esc, then Tab, leaves the editor · Ctrl-Space completes
54 lines · 1,456 / 20,000Starting the in-browser compiler…