React Buttons
Create TREND buttons using react.
Installation
npm install react react-dom
npm install @trend/react-button
Basic Usage
With a module bunlder like webpack, use as you would anything else:
@import React from 'react';
@import Button from '@trend/button';
function MyButton(props) {
return <Button {...props}>My Button</Button>;
}
functon CtabButton() {
return <Button variant="ctab">Ctab Button</Button>;
}
functon AccentCompactButton() {
return <Button accent size="flat">Accent Compact Button</Button>;
}
function ButtonWithIcon() {
return <Button>
{({ getButtonIconProps }) =>
<React.Fragment>
<Icon {...getButtonIconProps()} />
Button with icon
</React.Fragment>
}
</Button>
}
Props:
className
string
| optional, no default
Will automatically add tc-Button
to rendered button element.
accent
boolean
| defaults to false
Use the accent theme.
disabled
boolean
| defaults to false
size
string
| optional, no default
Can be "compact."
variant
string
| optional, no default
Can be any of "ctab", "flat", or "ghost."
type
string
| defaults button
Can be any one of button
, submit
, or reset
.
children
function({}) or node
| required
Children as function gets called with an object and is useful for rendering a child icon in a button element.
Property | Category | Type | Description |
---|
getButtonIconProps | prop getter | function(props: object) | Will return the props to apply to a icon as a child of a button element. |