Changing default styles

  • Jax Wedel

    6 months ago

    I am working on how styling can be done efficiently in Toddle, and I am trying to find out how to do a stylesheet for all elements. I want to avoid having to change every component every time, because that will cause issues and mistakes. But it seems Toddle doesnt support stylesheets, and the advice seems to be to create every element as components, and then style all of those components every time, and then insert them into the app instead of using the basic toddle elements. Which seems a bit strange since you are basically building a stylesheet one by one as components.

    Is this correct? Is there no other way to do a stylesheet?

    And regarding light/dark mode, I watched the video called "Lights on" https://www.youtube.com/watch?v=_HKZGI6UW_g
    @Andreas Møller mentions there that there is an easier way to do this in larger apps, is that video out? Because I would rather do two separate stylesheets than to build in this logic in every component.

    PS: I see a solution by creating a global variable like "light" and "dark". But not sure where you do that in Toddle (on root page/homepage?).
  • Andreas Møller

    6 months ago

    Hey, the plan is to support multiple themes.

    So you will have the same cars but different values for each theme.

    This is not available yet though
  • Jax Wedel

    6 months ago

    So how do you solve light/dark mode in a larger app now? you mentioened it in the video
  • Andreas Møller

    6 months ago

    You can override style variables at any level, so you can set the bars on the root element of each page.
  • Andreas Møller

    6 months ago

    You can also do it with a style tag if you prefer
    👍1
  • Aburio

    6 months ago

    @Jax Wedel If you want inpiration you can clone this package => https://toddle.dev/projects/nocode_ui/branches/main/components/Home?rightpanel=style

    live demo of the dark/light mode here => https://nocode_ui.toddle.site/
    🔥1
  • Jax Wedel

    6 months ago

    Thanks bro. Will check it out
  • Neville

    1 month ago

    @ what is a style tag?
  • Lucas G

    1 month ago

    For what its worth, you can actually use stylesheets in toddle
  • Not 'natively' though. For example, you can host a stylesheet elsewhere and load it in your headers
  • Then just add your classes to elements
  • It's not the toddle way but you can do it if you really want to
  • Or as Andreas said, type up your stylesheet in a <style> element and apply your classes elements.
  • Tod

    1 month ago

    Great energy @Lucas G! Your continuous contribution to the toddle Community just made you advance to Community Level 35!

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.