File tree 4 files changed +13
-2
lines changed
storybook/stories/Components
4 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,15 @@ type Props = {
18
18
isDisabled ?: boolean ;
19
19
size ?: ButtonSize ;
20
20
icon ?: ( props : IconProps ) => JSX . Element ;
21
+ iconPosition ?: "leading" | "trailing" ;
21
22
} & Omit < AriaButtonProps < "button" > , "onPress" > ;
22
23
23
24
/**
24
25
* A button
25
26
*/
26
27
export function Button ( props : Props ) {
27
28
const config = useBentoConfig ( ) . button ;
29
+ const iconPosition = props . iconPosition ?? config . defaultIconPosition ;
28
30
const ref = useRef < HTMLButtonElement > ( null ) ;
29
31
const { buttonProps } = useButton ( props , ref ) ;
30
32
const {
@@ -61,7 +63,7 @@ export function Button(props: Props) {
61
63
onPointerDown = { internal_unsafe__bypassUsePress ? undefined : buttonProps . onPointerDown }
62
64
onClick = { internal_unsafe__bypassUsePress ? props . onPress : buttonProps . onClick }
63
65
>
64
- < Columns space = { config . internalSpacing } alignY = "center" >
66
+ < Columns space = { config . internalSpacing } alignY = "center" reverse = { iconPosition === "trailing" } >
65
67
{ props . icon && (
66
68
< Column width = "content" >
67
69
{ props . icon ( {
Original file line number Diff line number Diff line change 1
1
import { IconProps } from "../Icons" ;
2
2
import { BentoSprinkles } from "../internal" ;
3
3
import { LabelProps } from "../Typography/Label/Label" ;
4
- import { ButtonSize } from "./Button" ;
4
+ import { ButtonProps , ButtonSize } from "./Button" ;
5
5
6
6
type SizeConfig < T > = {
7
7
[ k in ButtonSize ] : T ;
@@ -22,4 +22,5 @@ export type ButtonConfig = {
22
22
* @default "medium"
23
23
*/
24
24
defaultSize : ButtonSize ;
25
+ defaultIconPosition : ButtonProps [ "iconPosition" ] ;
25
26
} ;
Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ export const button: ButtonConfig = {
138
138
} ,
139
139
uppercaseLabel : true ,
140
140
defaultSize : "medium" ,
141
+ defaultIconPosition : "leading" ,
141
142
} ;
142
143
143
144
export const card : CardConfig = {
Original file line number Diff line number Diff line change @@ -93,3 +93,10 @@ export const WithIcon = createStory({
93
93
hierarchy : "primary" ,
94
94
icon : IconCheck ,
95
95
} ) ;
96
+
97
+ export const WithIconTrailing = createStory ( {
98
+ kind : "solid" ,
99
+ hierarchy : "primary" ,
100
+ icon : IconCheck ,
101
+ iconPosition : "trailing" ,
102
+ } ) ;
You can’t perform that action at this time.
0 commit comments