Loading...
Loading...
StyleX styling patterns using design tokens, breakpoints, and custom css prop. Use when working with styles, CSS, design tokens, breakpoints, responsive design, themes, styling components, css prop, stylex.create, or when the user mentions StyleX, tokens.stylex, controlSize, color tokens, or breakpoints.
npx skill4agent add qingqishi/shiqingqi.com stylex-styling@/tokens.stylex.tscolorcontrolSizefont@/breakpoints.babelrc.jssrc/babel.d.ts{ default: value, [breakpoints.md]: largeScreenValue }css={styles.someStyle}{...stylex.props(styles.someStyle)}css={[styles.base, isActive && styles.active]}import * as stylex from "@stylexjs/stylex";
import { breakpoints } from "@/breakpoints";
import { color, controlSize, font } from "@/tokens.stylex";
function Button({ children, isActive, hideLabelOnMobile, ...props }) {
return (
<button
{...props}
css={[
styles.button,
isActive && styles.active,
hideLabelOnMobile && styles.hideLabelOnMobile,
]}
>
{children}
</button>
);
}
const styles = stylex.create({
button: {
// Use design tokens
fontSize: controlSize._4,
fontWeight: font.weight_5,
minHeight: controlSize._9,
paddingBlock: controlSize._1,
paddingInline: controlSize._3,
// Responsive design with breakpoints
display: { default: "none", [breakpoints.md]: "inline-flex" },
// Theme-aware colors
color: color.textMain,
backgroundColor: {
default: color.backgroundRaised,
":hover": color.backgroundHover,
},
},
active: {
backgroundColor: color.controlActive,
color: color.textOnActive,
},
hideLabelOnMobile: {
paddingLeft: {
default: controlSize._3,
[breakpoints.md]: controlSize._2,
},
},
});{...stylex.props()}css={[base, condition && conditional]}{ default: value, ":hover": hoverValue }display: { default: "none", [breakpoints.md]: "flex" }css={[styles.base, isActive && styles.active, hasError && styles.error]}backgroundColor: {
default: color.backgroundRaised,
":hover": color.backgroundHover,
}padding: {
default: controlSize._2,
[breakpoints.md]: controlSize._4,
[breakpoints.lg]: controlSize._6,
}