Skip to content

Commit c602f69

Browse files
committed
📝 Update Button docs
1 parent a9ff379 commit c602f69

File tree

2 files changed

+90
-1
lines changed

2 files changed

+90
-1
lines changed

.internal/demo-theme.js

+8
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ export const theme = {
9191
default: {
9292
background: 'royalblue',
9393
color: 'white'
94+
},
95+
danger: {
96+
background: 'red',
97+
color: 'white'
98+
},
99+
success: {
100+
background: 'lime',
101+
color: 'white'
94102
}
95103
},
96104
Input,

docs/button.mdx

+82-1
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,93 @@ import { Button } from 'pss-components'
4141
### Change element
4242

4343
<Playground>
44-
<Button variant='auto' as='a' href='http://example.com' target='_blank'>
44+
<Button variant='auto' as='a' href='http://example.com' target='_blank' role='button'>
4545
Button
4646
</Button>
4747
</Playground>
4848

4949

50+
### Default styles
51+
52+
You can't change reset styles in `Button`, as in [Box](/box), but you can provide additional default styles for all buttons:
53+
54+
```js
55+
import { css } from '@emotion/core'
56+
57+
const myTheme = {
58+
// All Buttons will have border-radius and padding
59+
Button: css`
60+
border-radius: 5px;
61+
padding: 10px 20px;
62+
`
63+
}
64+
```
65+
66+
Please note that if you provide default style, you will not be able to change it with props, so I will recommend to create your own button instead:
67+
68+
```js
69+
// /my/components/button.js
70+
import { Button as ButtonBase } from 'pss-components'
71+
72+
const Button = (props) => (
73+
<ButtonBase
74+
px='10px'
75+
py='20px'
76+
borderRadius={5}
77+
{...props}
78+
/>
79+
)
80+
```
81+
82+
### Variants
83+
84+
You can add `Button` variants to theme for consistent usage:
85+
86+
```js
87+
const myTheme = {
88+
buttonStyle: {
89+
default: {
90+
background: 'royalblue',
91+
color: 'white'
92+
},
93+
danger: {
94+
background: 'red',
95+
color: 'white'
96+
},
97+
success: {
98+
background: 'lime',
99+
color: 'white'
100+
}
101+
}
102+
}
103+
```
104+
105+
<Playground>
106+
<Button variant='default'>
107+
Default
108+
</Button>
109+
</Playground>
110+
111+
Auto is same as `default`, but dynamic (see [ThemeDefaults](/theme-defaults))
112+
113+
<Playground>
114+
<Button variant='auto'>
115+
Auto
116+
</Button>
117+
</Playground>
118+
119+
<Playground>
120+
<Button variant='danger'>
121+
Danger
122+
</Button>
123+
</Playground>
124+
125+
<Playground>
126+
<Button variant='success'>
127+
Success
128+
</Button>
129+
</Playground>
130+
50131
## Props
51132

52133
<PropsTable of={Button} />

0 commit comments

Comments
 (0)