RoCSS - Write CSS-Like Code in Roblox

Hey everyone!
I just released a module called RoCSS and wanted to tell you about it. It’s incredibly simple, but I think it’s something that we all need when working with GUI. You can find the documentation here and the Roblox model here.

Why use this?
When you’re working with GUI as a Roblox Developer, it often gets annoying to keep track of your effects and styles. RoCSS eliminates this confusion by allowing you to define classes and their respective looks and effects in the form of a dictionary. Instead of copy and pasting multiple local scripts to manage hover effects for example, all you have to do with RoCSS is add a dictionary called “onhover” and you can define effects in there! You can also simply use it to apply styles to all GUIs with a certain tag at runtime.

How do I use this?
After inserting the RoCSS module script into Replicated Storage, you will need to do two things:

  1. Create a ModuleScript to store your styles
  2. Create a LocalScript in which you’ll require the two module scripts and initialize RoCSS by calling RoCSS.init(stylesheet: {}?).

How do I define styles?
You can define classes and their styles in your ModuleScript like this:

return {
	['class name'] = {
		["Property"] = "Value",
	},
}

How do I use classes?
RoCSS uses the built-in CollectionService to gather a table of all GUIs with a specific “class”. Classes are just tags, so to add an instance as a member of a class, simply add a tag with the class name to it.

For more info such as hover effects, please see the documentation

Have fun with this and tell me your suggestions!

14 Likes

This looks amazing and I can’t wait to try it in my games and utilise it!

2 Likes

well this is completely useless now
ui styling

1 Like

Yes, the class specific property values are now redundant as you can use UI styling to do the same thing. However, StyleSheets do not currently support any sort of animations, which is one of the more useful features of this module. Once this feature is added, I will deprecate this module.

1 Like

doc website down. says 404 page not found.

1 Like

oh ok thats interesting, ill look into it

Thanks for letting me know, I just updated the link. Should work now.

The GitHub page still appears as a 404.

My bad, I only updated one of the links. Fixed now :slight_smile: