#different color for hover effect in side bar
1 messages · Page 1 of 1 (latest)
Hi @fallow jackal. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
To change the color of the hover effect in Astro Starlight's sidebar, you can use custom CSS to override the default styles. Here are two approaches you can take:
Using Custom CSS
You can create a custom CSS file and add it to your Starlight configuration:
- Create a CSS file in your
src/directory, for examplesrc/styles/custom.css - Add CSS to target the sidebar hover effect:
.nav-links a:hover, a:focus {
background-color: #yourColorHere; /* Replace with your desired color */
}
- Add this CSS file to your Starlight configuration in
astro.config.mjs:
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';
export default defineConfig({
integrations: [
starlight({
title: 'Your Site Title',
customCss: [
// Path to your custom CSS file
'./src/styles/custom.css',
],
}),
],
});
Using Tailwind CSS
If you're using Tailwind with Starlight, you can customize the accent colors which affect the sidebar hover state:
@theme {
/* Your preferred accent color which affects sidebar hover */
--color-accent-50: var(--color-indigo-50);
--color-accent-100: var(--color-indigo-100);
/* ... other accent color variables ... */
--color-accent-600: var(--color-indigo-600);
--color-accent-700: var(--color-indigo-700);
/* ... */
}
You can also use Starlight's color theme editor to visually customize your accent colors and generate the CSS code: Starlight Color Theme Editor
The accent colors are used for links and highlighting the current item in navigation, so changing these will affect the sidebar hover effect.