--- name: scss description: SCSS styling architecture in RSX including component scoping, BEM naming, responsive breakpoints, and variables. Use when writing SCSS files, styling components, working with responsive design, or troubleshooting CSS conflicts. --- # RSX SCSS Architecture ## Component-First Philosophy Every styled element is a component with scoped SCSS. No CSS spaghetti - no generic classes like `.page-header` scattered across files. **Pattern vs Unique Decision**: - If you're copy-pasting markup, extract a component - Reusable structures → shared component with slots - One-off structures → page-specific component --- ## Directory Rules | Location | Purpose | Scoping | |----------|---------|---------| | `rsx/app/` | Feature components | Must wrap in component class | | `rsx/theme/components/` | Shared components | Must wrap in component class | | `rsx/theme/` (outside components/) | Primitives, variables, Bootstrap overrides | Global | | `rsx/lib/` | Non-visual utilities | No styles | --- ## Component Scoping (Required) SCSS in `rsx/app/` and `rsx/theme/components/` **must** wrap in a single component class: ```scss // dashboard_index_action.scss .Dashboard_Index_Action { padding: 2rem; .card { margin-bottom: 1rem; } .stats-grid { display: grid; gap: 1rem; } } ``` - Wrapper class matches JS class or Blade `@rsx_id` - Filename must match associated `.js` or `.blade.php` file - Components auto-render with `class="Component_Name"` on root --- ## BEM Child Classes Child classes use exact PascalCase component name as prefix: ```scss .DataGrid_Kanban { &__loading { /* .DataGrid_Kanban__loading */ } &__board { /* .DataGrid_Kanban__board */ } &__column { /* .DataGrid_Kanban__column */ } } ``` ```html