2025-11-23 20:12:09 -03:00
# Chapter 05: gbtheme CSS Theming
2025-11-23 09:19:06 -03:00
2025-11-23 20:12:09 -03:00
The `.gbtheme` package provides CSS-based styling for your bot's user interface. Themes control colors, fonts, layouts, and visual effects across all .gbui templates.
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
## Quick Start
2025-11-23 09:19:06 -03:00
2025-11-24 09:49:25 -03:00
To theme your bot, create a `.gbtheme` folder in your bot package and add a CSS file:
2025-11-23 09:19:06 -03:00
```
2025-11-23 13:46:55 -03:00
mybot.gbai/
└── mybot.gbtheme/
2025-11-24 09:49:25 -03:00
└── default.css # Your theme file
2025-11-23 09:19:06 -03:00
```
2025-11-24 09:49:25 -03:00
The theme loads automatically when the bot starts.
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
## How Themes Work
2025-11-23 09:19:06 -03:00
2025-11-24 09:49:25 -03:00
Themes are standard CSS files that override the default styles. The system loads them in this order:
1. System default styles
2. Your theme CSS file
3. Any inline style overrides
## Available Theme Files
You can create multiple theme files for different purposes:
- `default.css` - Main theme (loaded automatically)
- `dark.css` - Dark mode variant
- `print.css` - Print-friendly styles
- Custom theme names for special occasions
## Theme Elements to Style
### Core Components
- `.chat-container` - Main chat window
- `.message` - All messages
- `.message-user` - User messages
- `.message-bot` - Bot responses
- `.chat-input` - Input field
- `.send-button` - Send button
### UI Elements
- `.sidebar` - Side navigation
- `.header` - Top bar
- `.footer` - Bottom bar
- `.card` - Content cards
- `.button` - All buttons
- `.dialog` - Modal dialogs
### States and Interactions
- `.typing-indicator` - Typing animation
- `.loading` - Loading states
- `.error` - Error messages
- `.success` - Success messages
- `:hover` - Hover effects
- `:focus` - Focus states
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
## Switching Themes
2025-11-23 09:19:06 -03:00
2025-11-24 09:49:25 -03:00
Use the `CHANGE THEME` command in your BASIC scripts:
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
```basic
2025-11-24 09:49:25 -03:00
' Switch to dark theme
CHANGE THEME "dark"
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
' Back to default
CHANGE THEME "default"
```
2025-11-23 09:19:06 -03:00
2025-11-24 09:49:25 -03:00
## Theme Best Practices
2025-11-23 09:19:06 -03:00
2025-11-24 09:49:25 -03:00
1. **Start Simple** : Begin with colors and fonts, add complexity gradually
2. **Test Responsiveness** : Ensure your theme works on mobile devices
3. **Maintain Readability** : Keep sufficient contrast between text and backgrounds
4. **Use CSS Variables** : Define colors once, reuse throughout
5. **Test Dark Mode** : Many users prefer dark interfaces
2025-11-23 09:19:06 -03:00
2025-11-24 09:49:25 -03:00
## Pre-built Themes
2025-11-23 09:19:06 -03:00
2025-11-24 13:02:30 -03:00
General Bots includes example themes you can use as starting points:
2025-11-23 09:19:06 -03:00
2025-11-24 09:49:25 -03:00
- **default** - Clean, modern interface
- **3dbevel** - Retro Windows 95 style
- **minimal** - Simplified, distraction-free
- **corporate** - Professional business look
- **playful** - Colorful, fun design
2025-11-23 09:19:06 -03:00
2025-11-24 09:49:25 -03:00
## File Structure
2025-11-23 09:19:06 -03:00
2025-11-24 09:49:25 -03:00
Keep your theme files organized:
2025-11-23 09:19:06 -03:00
2025-11-24 09:49:25 -03:00
```
mybot.gbtheme/
├── default.css # Main theme
├── dark.css # Dark variant
├── mobile.css # Mobile-specific styles
└── assets/ # Images, fonts
├── logo.png
└── fonts/
```
2025-11-23 09:19:06 -03:00
2025-11-23 13:46:55 -03:00
## Loading Order
2025-11-23 09:19:06 -03:00
2025-11-24 09:49:25 -03:00
Themes are applied in a specific order to ensure proper cascading:
1. Base system styles (always loaded)
2. Theme file specified in config or `default.css`
3. Media queries for responsive design
4. User preference overrides (if any)
## Dynamic Theme Changes
Themes can be changed at runtime without restarting:
```basic
' Change theme based on time of day
hour = HOUR(NOW())
IF hour >= 18 OR hour < 6 THEN
CHANGE THEME "dark"
ELSE
CHANGE THEME "default"
END IF
```
## Troubleshooting
### Theme Not Loading
- Check file is named correctly (e.g., `default.css` )
- Verify `.gbtheme` folder is in the right location
- Restart the bot after adding new theme files
### Styles Not Applying
- Check CSS syntax is valid
- Use browser developer tools to inspect elements
- Verify selectors match the HTML structure
- Clear browser cache if changes aren't visible
### Performance Issues
- Minimize complex animations
- Optimize image sizes
- Avoid too many web fonts
- Use CSS transforms instead of position changes
2025-11-24 13:02:30 -03:00
## Beyond Themes: Full UI Customization
While themes provide CSS styling, you have more powerful options for UI customization:
### Extend the Default UI
You can modify the `.gbui` package to create custom HTML structures:
- Copy and modify the default UI templates
- Add your own components and layouts
- Create entirely new interaction patterns
- The bot will use your custom UI automatically
### Build Your Own UI Framework
General Bots is designed as a foundation for your projects:
- Fork the repository and customize everything
- Create industry-specific interfaces
- Develop unique bot experiences
- Use it as a base for commercial products
### Join the Community
**We actively encourage contributions!**
- Submit UI improvements via pull requests
- Share creative themes with others
- Develop new UI paradigms
- Help improve documentation
The UI layer is completely independent - you're free to reimagine how users interact with bots. The core engine provides the intelligence, you provide the experience.
### Getting Started
1. Fork the [General Bots repository ](https://github.com/GeneralBots/botserver )
2. Study the default.gbui structure
3. Experiment with your own designs
4. Share your innovations with the community
Remember: It's just HTML/CSS/JS talking to the bot via WebSocket. You have complete creative freedom!
2025-11-24 09:49:25 -03:00
## Summary
2025-11-23 09:19:06 -03:00
2025-11-24 09:49:25 -03:00
The `.gbtheme` system keeps styling simple and separate from bot logic. Just drop a CSS file in the `.gbtheme` folder and your bot gets a new look. Focus on the essentials - colors, fonts, and spacing - and let the default styles handle the rest.
2025-11-23 20:12:09 -03:00
2025-11-24 13:02:30 -03:00
For deeper customization, extend the `.gbui` package or build your own UI framework. General Bots is meant to be a starting point for your creativity!
2025-11-23 20:12:09 -03:00
## See Also
- [Chapter 4: .gbui Interface ](../chapter-04-gbui/README.md ) - User interface templates
2025-11-24 09:49:25 -03:00
- [Chapter 2: Packages ](../chapter-02/README.md ) - Package structure
- [Chapter 6: BASIC Dialogs ](../chapter-06-gbdialog/README.md ) - Using CHANGE THEME command
2025-11-24 14:15:01 -03:00
- [Chapter 8: Configuration ](../chapter-08-config/README.md ) - Theme configuration options
---
< div align = "center" >
< img src = "https://pragmatismo.com.br/icons/general-bots-text.svg" alt = "General Bots" width = "200" >
< / div >