The UiBox approach shifts the paradigm of separating styles into separate stylesheets by treating markup and styles as a single concern: Presentation. This method leverages CSS-in-JS to eliminate awkward naming conventions, remove the need for class name concatenation for dynamic props, and keep presentation logic in one place. It allows developers to define strict design system rules and understand layout relations directly where the component is used.
// Example of a dynamic styled component implementation
const UiBox = styled.div`
display: flex;
${({ width }) => width && `width: ${width}rem;`}
`
// Usage of the component with layout props
<UiBox
pad={5}
height={20}
width="100%"
direction="column"
align="center"
valign="center"
background="dark-3"
position="relative"
>
{/* Content */}
</UiBox>