You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/styling/custom-stylesheets.md
+70Lines changed: 70 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,6 +63,76 @@ app.add_page(
63
63
)
64
64
```
65
65
66
+
## SASS/SCSS Support
67
+
68
+
Reflex supports SASS/SCSS stylesheets alongside regular CSS. This allows you to use more advanced styling features like variables, nesting, mixins, and more.
69
+
70
+
### Using SASS/SCSS Files
71
+
72
+
To use SASS/SCSS files in your Reflex app:
73
+
74
+
1. Create a `.sass` or `.scss` file in your `assets` directory
75
+
2. Reference the file in your `rx.App` configuration just like you would with CSS files
76
+
77
+
```python
78
+
app = rx.App(
79
+
stylesheets=[
80
+
"/styles.scss", # This path is relative to assets/
81
+
"/sass/main.sass", # You can organize files in subdirectories
82
+
],
83
+
)
84
+
```
85
+
86
+
Reflex automatically detects the file extension and compiles these files to CSS using the `libsass` package.
87
+
88
+
### Example SASS/SCSS File
89
+
90
+
Here's an example of a SASS file (`assets/styles.scss`) that demonstrates some of the features:
91
+
92
+
```scss
93
+
// Variables
94
+
$primary-color: #3498db;
95
+
$secondary-color: #2ecc71;
96
+
$padding: 16px;
97
+
98
+
// Nesting
99
+
.container {
100
+
background-color: $primary-color;
101
+
padding: $padding;
102
+
103
+
.button {
104
+
background-color: $secondary-color;
105
+
padding: $padding/2;
106
+
107
+
&:hover {
108
+
opacity: 0.8;
109
+
}
110
+
}
111
+
}
112
+
113
+
// Mixins
114
+
@mixinflex-center {
115
+
display: flex;
116
+
justify-content: center;
117
+
align-items: center;
118
+
}
119
+
120
+
.centered-box {
121
+
@includeflex-center;
122
+
height: 100px;
123
+
}
124
+
```
125
+
126
+
### Dependency Requirement
127
+
128
+
The `libsass` package is required for SASS/SCSS compilation. If it's not installed, Reflex will show an error message. You can install it with:
129
+
130
+
```bash
131
+
pip install "libsass>=0.23.0"
132
+
```
133
+
134
+
This package is included in the default Reflex installation, so you typically don't need to install it separately.
135
+
66
136
## Fonts
67
137
68
138
You can take advantage of Reflex's support for custom stylesheets to add custom fonts to your app.
0 commit comments