In addition to the props detailed below, all layout components also have access to the props mentioned in the common API section.
The style
prop allows passing inline CSS styles. This prop is available on all standard
HTML elements in addition to the components in this library. Use inline styles to add CSS
styles that are not supported in the common API.
Note that inline styles do not have direct access to theme values, and cannot use the responsive style syntax.
Live Demo
Alternatively, make a new styled-component
and add the CSS styles there.
import styled from 'styled-components'import { Box } from '@intouchg/components'const CursorBox = styled(Box)`cursor: pointer;transform: scale3d(1.5, 0.75, 1);`
Inline styles should also be used for styles that are updated outside the react render cycle - such as values from react-spring.
The sx
prop takes an object with CSS selectors as keys, and style objects as values.
These style objects have access to theme values, just like the common API,
and can use responsive styles.
Live Demo
Live Demo
If you create your own styled-components
, you can add the sx
property to them using the function
exported from this library. You can also combine this with the styleFunctions
mentioned in
Getting Started.
import styled from 'styled-components'import { styleFunctions, sx } from '@intouchg/components'const MyHeading = styled.h1`font-size: 2rem;${styleFunctions}${sx}`
The as
polymorphic prop allows switching
out the element or component being rendered while keeping all the component styles. You can pass strings
for HTML element names or functions for React components.
If you create your own styled-components
, they will automatically have access to the as
prop.
Live Demo
This paragraph element has fancy heading styles
Live Demo
Live Demo