dosubot[bot] commented on issue #30933:
URL: https://github.com/apache/superset/issues/30933#issuecomment-2483318423
<!-- Answer -->
In a pip-installed Superset environment, you can still apply custom CSS by
using the `CssTemplate` model to manage and apply styles. Here's how you can do
it:
1. **Create a CSS Template**: You can define a CSS template in Python and
load it into the Superset database. This allows you to apply custom styles
across the application.
2. **Example CSS Template**: You can create a Python script to add your
custom CSS to the database. Here's a basic example:
```python
from superset import db
from superset.models.core import CssTemplate
# Define your custom CSS
custom_css = """
.navbar-brand img {
width: 200px; /* Adjust the width as needed */
height: auto; /* Maintain aspect ratio */
}
"""
# Create a new CSS template
css_template = CssTemplate(
template_name='Custom Logo Size',
css=custom_css
)
# Add the template to the database
db.session.add(css_template)
db.session.commit()
```
3. **Apply the CSS Template**: Once the template is added to the database,
you can apply it through the Superset UI by selecting it in the appropriate
settings or dashboard configuration.
This approach allows you to manage your custom styles without needing direct
access to the frontend codebase.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]