Migrate from v10
Smooth UI v11 is a big breaking change and the migration from v10 could be difficult. This guide will help you achieve it.
Previous documentation
The previous documentation is still accessible and will remain accessible on this url:
https://smooth-ui-v10.smooth-code.com
System
@smooth-ui/system is replaced by @xstyled/system. The behaviour is the same and everything is documented.
Normalize
- No breaking change.
Theming
Smooth UI v11 follows [xstyled theme specification](a new theme specification).
ThemeProvider has no breaking change, it still uses the one provided either by styled-component or by emotion-theming.
Emotion
Smooth UI v11 is still compatible with emotion.
Forms
Form layouts have been reimplemented to improve accessibility, see new Form documentation.
- FormGroupbecomes- FormField
- Labelbecomes- FormFieldLabel
- controlprop is no longer required
Grid
- Gridis gone, you can reimplement it:
// Example of a custom `Grid` componentconst Grid = styled.div`margin: 0 auto;max-width: 800px;padding: 0 20px;`
- Rowand- Colare now available everywhere as- rowand- colproperty, see xstyled documentation.
// v10import { Grid, Row, Col } from '@smooth-ui/core-sc'function Example() {return (<Grid><Row><Col xs={12} md={4}>One</Col><Col xs={12} md={4}>Two</Col><Col xs={12} md={4}>Three</Col></Row></Grid>)}// v11import { Box } from '@smooth-ui/core-sc'function Example() {return (<Box mx="auto" px={20} maxWidth={800}><Box row><Box col={{ xs: 1, md: 4 / 12 }}>One</Box><Box col={{ xs: 1, md: 4 / 12 }}>Two</Box><Box col={{ xs: 1, md: 4 / 12 }}>Three</Box></Box></Box>)}
Components
Alert
No breaking change, you have nothing to migrate.
Box
- Boxcomes now from @xstyled/system but for convenience it is also re-exported from- @smooth-ui/core-scand- @smooth-ui/core-em.
- It implements a new theme specification
Button
- Buttonuses Reakit Button to improve its accessibility
- Property sizeis nowscale
Checkbox
- Checkboxuses Reakit Checkbox to improve its accessiblity
- Property sizeis nowscale
- Property validis nowaria-invalid(inversed)
FormCheck
- Property inlineis gone, you can now usearia-orientationonRadioGrouporCheckboxGroup
Input
- Property sizeis nowscale
- Property validis nowaria-invalid(inversed)
Modal
- Modalis gone, you have to implement your own with Reakit Dialog
Popover
- Popoveris gone, you have to implement your own with Reakit Popover
Radio
- Radiouses Reakit Radio to improve its accessiblity
- It now requires a RadioGroupand auseRadioStateto work
- Property sizeis nowscale
- Property validis nowaria-invalid(inversed)
Select
- Property sizeis nowscale
- Property validis nowaria-invalid(inversed)
Switch
- The inner component has changed, if you style it, you have to adapt it
Textarea
- Property sizeis nowscale
- Property validis nowaria-invalid(inversed)
Tooltip
- Tooltipis gone, you have to implement your own with Reakit Tooltip
Typography
- Typographyis gone, you have to implement your own
Utilities
Breakpoint
The utility has been removed, you can do it with a Box:
// v10<Breakpoint down="md">Displayed down to md</Breakpoint>// v11<Box display={{ md: 'none' }}>Displayed down to md</Box>
// v10<Breakpoint up="md">Displayed up to md</Breakpoint>// v11<Box display={{ xs: 'none', md: 'block' }}>Displayed up to md</Box>
SwitchState
SwitchState is gone, use directly Reakit Checkbox to implement the same kind of behaviour.
Toggler
Toggler is gone, use React.useState instead.
// v10import { Toggler } from '@smooth-ui/core-sc'function Example() {return (<Toggler defaultToggled>{([toggled, onToggle]) => (<Button onClick={onToggle}>{toggled ? 'ON' : 'OFF'}</Button>)}</Toggler>)}// v11import React from 'react'function Example() {const [toggled, setToggled] = React.useState(true)return (<Button onClick={() => setToggled(x => !x)}>{toggled ? 'ON' : 'OFF'}</Button>)}
styled & css
styled and css are no longer exported from @smooth-ui/core-sc / @smooth-ui/core-em, you can import them from from @xstyled/styled-components / @xstyled/emotion if you want to use it.
Styled Components:
// v10import { styled, css } from '@smooth-ui/core-sc'// v11import styled, { css } from '@xstyled/styled-components'
Emotion:
// v10import { styled, css } from '@smooth-ui/core-em'// v11import styled, { css } from '@xstyled/emotion'
th
th utility is now exported from @xstyled/system and it is improved.
// v10import { th } from '@smooth-ui/core-sc'// v11import { th } from '@xstyled/system'
unit, px
unit and px are not longer exported. Use th.px instead.
// v10import { th } from '@smooth-ui/core-sc'css`font-size: ${px(10)};`// v11import { th } from '@xstyled/system'css`font-size: ${th.px(10)};`
up, down, between
Responsive utilities are now exported from @xstyled/system, see documentation.
// v10import { up, down, between } from '@smooth-ui/core-sc'// v11import { up, down, between } from '@xstyled/system'