SocialButton
To implement SocialButton component into your project you’ll need to add the import:
import SocialButton from "@kiwicom/orbit-components/lib/SocialButton";
After adding import into your project you can use it simply like:
<SocialButton>Hello World!</SocialButton>
Props
Table below contains all types of the props available in SocialButton component.
| Name | Type | Default | Description | 
|---|---|---|---|
| ariaControls | string | Id of the element the button controls. | |
| ariaExpanded | boolean | Tells screen reader the controlled element from ariaControlsis expanded | |
| asComponent | string \| React.Element | "button" | The component used for the root node. | 
| fullWidth | boolean | false | If true, the SocialButton will grow up to the full width of its container. | 
| children | React.Node | The content of the SocialButton. See Functional specs | |
| dataTest | string | Optional prop for testing purposes. | |
| id | string | Set idforSocialButton | |
| disabled | boolean | false | If true, the SocialButton will be disabled. | 
| external | boolean | false | If true, the SocialButton opens link in a new tab. See Functional specs | 
| href | string | The URL of the link to open when SocialButton is clicked. See Functional specs | |
| loading | boolean | false | If true, the loading glyph will be displayed. | 
| onClick | event => void \| Promise | Function for handling onClick event. | |
| ref | func | Prop for forwarded ref of the SocialButton. | |
| role | string | Specifies the role of an element. | |
| size | enum | "normal" | The size of the SocialButton. | 
| spaceAfter | enum | Additional margin-bottomafter component. | |
| submit | boolean | false | If true, the SocialButton will havetype="submit"attribute, otherwisetype="button". | 
| tabIndex | string \| number | Specifies the tab order of an element. | |
| title | string | Adds aria-label. | |
| type | enum | "apple" | The type of SocialButton. | 
| width | string | The width of the SocialButton. Can be any string - 100px,20%. | 
enum
| type | size | spaceAfter | 
|---|---|---|
| "apple" | "small" | "none" | 
| "facebook" | "normal" | "smallest" | 
| "google" | "large" | "small" | 
| "X" | "normal" | |
| "email" | "medium" | |
| "large" | ||
| "largest" | 
Functional specs
- When the externalis specified,noopenervalue will be automatically added to attributerelfor security reason.
- By passing the hrefprop into SocialButton, it will render intoaelement. If you passasComponentprop it will override this logic.
- If you want to use the - asComponentprop then YourComponent should accept at least- className. Otherwise it won’t be rendered with proper styling, e.g.:const YourComponent = props => <div {...props} /><SocialButton asComponent={YourComponent}>Title</SocialButton>- If you specify the children of YourComponent component, it will override the children prop of SocialButton component, e.g.: const YourComponent = props => <div {...props}>YourComponent</div>;
Accessibility
A button is mainly used for indicating an action, submitting a data, opening a modal etc. If you want to use SocialButton for navigation consider using a <TextLink> for that.
- Use - ariaControlsprop to add- aria-controlsattribute to establish the relationship between button and element which is controlled by it.- aria-controlsworks only with a unique- idof an element.
- Use - ariaExpandsprop to add- aria-expandsto indicate screenreaders, that element controlled by button through- ariaControlsis expanded or not.
- Use - disabledprop to indicate users that button is inactive and they can’t interact with it.
- Use - roleand- tabIndexwhen you are rendering- SocialButtonto non-actionable HTML element as- divor- span. However, this should be done only in edge-cases as it is anti-pattern behavior.
- Use - titleto add- aria-labelwhen you need to add extra informations to screen readers or there is no- childrenpresented to be used as label.