@@ -5,7 +5,9 @@ description: Triggers a click action usually performed by the user to trigger an
5
5
---
6
6
7
7
<Preview >
8
- <Button variant = " primary" >Primary button</Button >
8
+ <Button variant = " solid" color = " accent" >
9
+ Solid button
10
+ </Button >
9
11
</Preview >
10
12
11
13
## Usages
@@ -26,109 +28,132 @@ Import all parts and piece them together.
26
28
<LiveEditor code = { `
27
29
import { Button } from '@raystack/apsara/v1'
28
30
29
- <Button variant="primary ">Click here!</Button> ` } border />
31
+ <Button variant="solid" color="accent ">Click here!</Button> ` } border />
30
32
</LiveProvider >
31
33
32
-
33
34
## Props
34
35
35
36
The ` Button ` component accepts the following props:
36
37
37
- - ` variant ` : Visual style variant (` "primary" ` | ` "secondary" ` | ` "outline" ` | ` "ghost" ` | ` "danger" ` | ` "text" ` , default: "primary")
38
+ - ` variant ` : Visual style variant (` "solid" ` | ` "outline" ` | ` "ghost" ` | ` "text" ` , default: "solid")
39
+ - ` color ` : Color theme (` "accent" ` | ` "danger" ` | ` "neutral" ` | ` "success" ` , default: "accent")
38
40
- ` size ` : Size of the button (` "small" ` | ` "normal" ` , default: "normal")
39
41
- ` disabled ` : Whether the button is disabled (boolean, default: false)
40
42
- ` loading ` : Shows a loading spinner inside the button (boolean)
41
43
- ` loaderText ` : Optional text to display next to the loading spinner (ReactNode)
42
44
- ` leadingIcon ` : Icon element to display before button text (ReactNode)
43
45
- ` trailingIcon ` : Icon element to display after button text (ReactNode)
46
+ - ` maxWidth ` : Custom maximum width for the button (string | number)
44
47
- ` width ` : Custom width for the button (string | number)
45
48
- ` asChild ` : Boolean to merge props onto child element
46
49
- ` className ` : Additional CSS class names
47
50
- All other ButtonHTMLAttributes from React
48
51
52
+ ## Variants
49
53
50
- ## Variant
51
-
52
- Variants allow you to customize the button's style, making it visually distinctive and suitable for different purposes. Default is ` Primary ` .
54
+ Variants allow you to customize the button's style, making it visually distinctive and suitable for different purposes. Default is ` solid ` .
53
55
54
56
<Playground
55
57
scope = { { Button }}
56
58
tabs = { [
57
59
{
58
- name: " Primary" ,
59
- code: ` <Button variant="primary">Primary button</Button> ` ,
60
- },
61
- {
62
- name: " Secondary" ,
63
- code: ` <Button variant="secondary">Secondary button</Button> ` ,
60
+ name: " Solid" ,
61
+ code: ` <Button variant="solid" color="accent">Solid button</Button> ` ,
64
62
},
65
63
{
66
64
name: " Outline" ,
67
- code: ` <Button variant="outline">Outline button</Button> ` ,
65
+ code: ` <Button variant="outline" color="accent" >Outline button</Button> ` ,
68
66
},
69
67
{
70
68
name: " Ghost" ,
71
69
code: ` <Button variant="ghost">Ghost button</Button> ` ,
72
70
},
73
- {
74
- name: " Danger" ,
75
- code: ` <Button variant="danger">Danger button</Button> ` ,
76
- },
77
71
{
78
72
name: " Text" ,
79
73
code: ` <Button variant="text">Text button</Button> ` ,
80
74
},
81
75
]}
82
76
/>
83
77
78
+ ## Colors
79
+
80
+ Colors help convey the purpose and importance of actions. The color prop only affects solid and outline variants. Default is ` accent ` .
81
+
82
+ <Playground
83
+ scope = { { Button }}
84
+ tabs = { [
85
+ {
86
+ name: " Accent" ,
87
+ code: `
88
+ <div style={{display:'flex', gap: '8px'}}>
89
+ <Button variant="solid" color="accent">Solid</Button>
90
+ <Button variant="outline" color="accent">Outline</Button>
91
+ </div> ` ,
92
+ },
93
+ {
94
+ name: " Danger" ,
95
+ code: `
96
+ <div style={{display:'flex', gap: '8px'}}>
97
+ <Button variant="solid" color="danger">Solid</Button>
98
+ <Button variant="outline" color="danger">Outline</Button>
99
+ </div> ` ,
100
+ },
101
+ {
102
+ name: " Neutral" ,
103
+ code: `
104
+ <div style={{display:'flex', gap: '8px'}}>
105
+ <Button variant="solid" color="neutral">Solid</Button>
106
+ <Button variant="outline" color="neutral">Outline</Button>
107
+ </div> ` ,
108
+ },
109
+ {
110
+ name: " Success" ,
111
+ code: `
112
+ <div style={{display:'flex', gap: '8px'}}>
113
+ <Button variant="solid" color="success">Solid</Button>
114
+ <Button variant="outline" color="success">Outline</Button>
115
+ </div> ` ,
116
+ },
117
+ ]}
118
+ />
84
119
85
120
## Scale
86
121
87
- The Button component offers two size options to accommodate various design requirements. By selecting the ` normal ` size, you can create buttons that are visually larger, making it more prominent and noticeable within the user interface . Default size is ` normal ` .
122
+ The Button component offers two size options. Default size is ` normal ` .
88
123
89
124
<Playground
90
125
scope = { { Button }}
91
126
tabs = { [
92
127
{
93
128
name: " Small" ,
94
- code: ` <Button variant="primary" size="small">primary button</Button> ` ,
129
+ code: ` <Button variant="solid" color="accent" size="small">Small button</Button> ` ,
95
130
},
96
131
{
97
132
name: " Normal" ,
98
- code: ` <Button variant="primary" size="normal">primary button</Button> ` ,
133
+ code: ` <Button variant="solid" color="accent" size="normal">Normal button</Button> ` ,
99
134
},
100
135
]}
101
136
/>
102
137
103
138
## Disabled
104
139
105
- The Button component provides a "disabled" state, which prevents the button from responding to any user actions. When a button is disabled, it becomes unclickable and does not trigger any associated actions or events.
106
-
107
- This feature is useful when you want to indicate that a button is temporarily inactive or unavailable for interaction. Default is ` false ` .
140
+ The Button component provides a "disabled" state, which prevents the button from responding to any user actions. Default is ` false ` .
108
141
109
142
<Playground
110
143
scope = { { Button }}
111
144
tabs = { [
112
145
{
113
- name: " Primary" ,
114
- code: ` <Button disabled variant="primary">Primary button</Button> ` ,
115
- },
116
- {
117
- name: " Secondary" ,
118
- code: ` <Button disabled variant="secondary">Secondary button</Button> ` ,
146
+ name: " Solid" ,
147
+ code: ` <Button disabled variant="solid" color="accent">Solid button</Button> ` ,
119
148
},
120
149
{
121
150
name: " Outline" ,
122
- code: ` <Button disabled variant="outline">Outline button</Button> ` ,
151
+ code: ` <Button disabled variant="outline" color="accent" >Outline button</Button> ` ,
123
152
},
124
153
{
125
154
name: " Ghost" ,
126
155
code: ` <Button disabled variant="ghost">Ghost button</Button> ` ,
127
156
},
128
- {
129
- name: " Danger" ,
130
- code: ` <Button disabled variant="danger">Danger button</Button> ` ,
131
- },
132
157
{
133
158
name: " Text" ,
134
159
code: ` <Button disabled variant="text">Text button</Button> ` ,
@@ -138,32 +163,30 @@ This feature is useful when you want to indicate that a button is temporarily in
138
163
139
164
## Loading
140
165
141
- The Button component offers inbuilt loading states. Loading state is used to signify an ongoing process after the user has clicked on the button. Loading is an optional prop.
142
-
143
- Note: A loading as ` true ` only disables the button click and displays a spinner within the button. ` loading ` does not changes the button appearance as disabled. For changing the appearance to disabled state, a ` disabled ` prop as ` true ` has to passed.
166
+ The Button component offers inbuilt loading states. Loading state is used to signify an ongoing process after the user has clicked on the button.
144
167
145
168
<Playground
146
169
scope = { { Button }}
147
170
code = { `
148
171
<div style={{display:'flex', gap: '8px'}}>
149
- <Button variant="primary" loading>Click here </Button>
150
- <Button variant="primary" loading loaderText="Custom Loading...">Click here </Button>
151
- <Button variant="primary" loading loaderText="Loading..." disabled>Click here </Button>
172
+ <Button variant="solid" color="accent" loading>Loading </Button>
173
+ <Button variant="solid" color="accent" loading loaderText="Custom Loading...">Loading </Button>
174
+ <Button variant="solid" color="accent" loading loaderText="Loading..." disabled>Loading </Button>
152
175
</div>
153
176
` }
154
177
/>
155
178
156
179
## With leading and trailing icons
157
180
158
- The button component accepts optional leading and/or trailing icons. A ` ReactNode ` can be passed as a prop.
181
+ The button component accepts optional leading and/or trailing icons.
159
182
160
183
<Playground
161
184
scope = { { Button }}
162
185
code = { `
163
186
<div style={{display:'flex', gap: '8px'}}>
164
- <Button variant="primary " leadingIcon={<>I</>}>With leading icon</Button>
165
- <Button variant="primary " trailingIcon={<>O</>}>With trailing icon</Button>
166
- <Button variant="primary " leadingIcon={<>I</>} trailingIcon={<>O</>}>With both icons</Button>
187
+ <Button variant="solid" color="accent " leadingIcon={<>I</>}>With leading icon</Button>
188
+ <Button variant="solid" color="accent " trailingIcon={<>O</>}>With trailing icon</Button>
189
+ <Button variant="solid" color="accent " leadingIcon={<>I</>} trailingIcon={<>O</>}>With both icons</Button>
167
190
</div>
168
191
` }
169
192
/>
0 commit comments