Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Superset UI styling extension framework #27011

Closed

Conversation

mknadh
Copy link
Contributor

@mknadh mknadh commented Feb 5, 2024

#25012
feat: Superset UI styling extension framework #27011

SUMMARY

Customizing Buttons and Navigation in Superset through Theming

Superset has allowed limited UI customization via the THEME_OVERRIDES configuration. This exposes only font and colour changes for certain elements like buttons and navigation links.

This approach has some drawbacks:
• Styles are restricted to typography and colours only. Properties like borders, shadows, opacity and more remain inaccessible.
• Identical HTML attributes for semantic elements make selective styling difficult. The "Create Dashboard" primary call-to-action button uses the same classes as secondary "Bulk Action" buttons.
• Classes and selectors for customization are not clearly documented.

To address this, theming capabilities have been enhanced significantly:
• A new theme file can override styles for most UI elements based on class names, HTML tags and component hierarchy. Examples now exist for styling specific buttons, dropdowns, tables and more.
• Full access to modify colours, fonts, spacing, borders, shadows and more for targeted elements.
• Improved documentation for Superset's React hierarchy and class names to simplify theme crafting.

This grants administrators more flexibility in customizing branding aesthetics, tweaking interactions, enhancing readability and ensuring accessibility needs without wrestling overrides at a component level.

The updated theming system aims to balance standardization that aids rapid development with customization pathways vital for diverse dashboard consumers.

Apache Superset’s extension to customize Superset's Appearance with Theming:

This extension allows administrators to customize various aspects of the superset UI appearance without needing to override React components.

What Can Be Customized?

The theming file theme.less allows changing colors, typography, borders, shadows, and more for elements like:

  • Buttons
  • Links
  • Input fields
  • Select dropdowns
  • Menu items
  • Tab navigation
  • Tables
  • Modals
  • Loaders
  • Toasts

And more based on their HTML tags, CSS classes and attributes.

How Theming Works?

• Defining Styles: This involves specifying the visual properties of various elements such as text, buttons, backgrounds, etc. Styles can include attributes like colors, fonts, borders, and more.
For example:
// Color mixins
.setColor(@name, @color: black) {
.bg-@{name} {
background-color: @color !important;
}
.text-@{name} {
color: @color !important;
}
.border-@{name} {
border-color: @color !important;
}
.placeholder-@{name} {
border-color: @color !important;
}
}

• Creating Theme Files: Theme files contain the style definitions and are often separate from the core application code. This separation allows for easier maintenance and updates.
For example:
// Primary button theme
.btn-primary {
.bg-blue-600;
.border-blue-600;
}

// Input theme
input.form-control {
.font-sans;
.bg-white;
.border;
.border-gray-600;
.placeholder-gray-600;
.text-sm;
.text-gray-800;
}

• Importing Themes: This process involves loading the appropriate theme files and applying the defined styles.
Import theme.less file in /superset-frontend/src/theme.ts file.
// Importing custom theme.
import './assets/stylesheets/custom/theme.less';

• Restart Superset server to apply the defined styles

Benefits

  • enhances the user experience by providing a personalized and visually appealing interface
  • Granular control over many UI elements without editing components
  • Change colours, typography, padding, borders, shadows and more
  • Apply organization branding and themes

Enabling custom theme in the application

• Import theme.less file in /superset-frontend/src/theme.ts file.
// Importing custom theme.
import './assets/stylesheets/custom/theme.less';

To enable custom loading indicator in the application
• Change the Loader image path from src/assets/images/loading.gif to src/assets/images/custom/loading.gif in the following files:
o /superset-frontend/src/components/Loading/index.tsx
o /superset-frontend/src/components/Loading/Loading.test.tsx
o /superset/templates/superset/basic.html
o /superset-frontend/src/features/datasets/AddDataset/DatasetPanel/DatasetPanel.tsx

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️

We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register.

@rusackas
Copy link
Member

rusackas commented Feb 5, 2024

Thank you for opening the PR, but I'm afraid it's taking things backward in terms of where the project intends to go.

Superset was originaly built with LESS styling, but that has posed a lot of issues over the years in terms of growth, maintenance, and customization. Because of that, we're actually trying to progressively get RID of all of the LESS code in Superset.

We're steering toward Emotion to use CSS-in-JS techniques that will give us contained styling of our component system, and also supports theming and customization in numerous ways. The THEME_OVERRIDES you speak of is a relatively new addition to support where this is going but it's not a final state. You can read more about this in the related SIP and this blog post.

@mistercrunch
Copy link
Member

If you want to contribute to the "themability" of Superset, I'm sure we can orient you in the right direction so you can work on the most impactful and most visible areas of the codebase.

@SatishMulchandani
Copy link

@mistercrunch we are eager to contribute to the "themability" of Superset. Could you please provide guidance on the most impactful and visible areas of the codebase? We are keen to make a meaningful impact.

@mistercrunch
Copy link
Member

#20159

@geido
Copy link
Member

geido commented Feb 16, 2024

@SatishMulchandani are you available in Superset Slack? I think it would be great to organize around this effort. @michael-s-molina and I can give you all the context required to make a successful contribution toward themability. Feel free to reach out

@rusackas
Copy link
Member

rusackas commented Dec 9, 2024

Closing this out since it hasn't been touched in quite some time, but we'd be happy to reopen it if you ever want to revisit/update it!

@rusackas rusackas closed this Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants