LogoSuchi

Styling

Suchi comes with some basic styling to quickly setup an article or page. However, you can easily style the Index according to your design.

The fastest way to style the article according to your sites brand color is by using the accentColor prop in Index. The accentColor is applied to the active Indicator and active Index Item.

You can also target the accentColor using CSS variables as show below:

[data-suchi-root] {
  --suchi-accentColor: purple !important;
}
 
//For dark mode
.dark [data-suchi-root] {
  --suchi-accentColor: yellow !important;
}

Mastering React Hooks

Introduction

Getting Started

Advanced Techniques

Best Practices

Conclusion


Colors

Suchi uses some CSS Variables to apply colors to various Suchi elements.

VariableDefaultTarget
--suchi-accentColorhsl(9, 100%, 59%)Active index item and indicator
--suchi-inactive-indicatorhsl(0, 0%, 65%)Inactive indicator
--suchi-inactive-itemhsl(0, 3%, 34%)Inactive items in the Index Tray
--suchi-background-colorhsl(0, 0%, 100%)Background Color for the Index Tray
--suchi-scrollbar-colorhsl(0, 0%, 69%)Scrollbar color in the Index Tray

You can use a custom color palette for your page by replacing these CSS Variables.

Use the !important flag while styling to override default CSS styling.

Example:

[data-suchi-root] {
  --suchi-background-color: #111827 !important;
}


Styling Elements

Learn about the various Suchi Elements here.

Indicators

Indicators are organized within a <ul> tag.

To style or target the indicators, use the attribute selector [data-suchi-indicators]. Each indicator, represented by an <li> element, can be targeted using [data-suchi-indicator].

The indicator corresponding to the section currently in view will have an "active" state: [data-suchi-indicator="active"]. All other indicators will default to the "inactive" state: [data-suchi-indicator="inactive"].

Interactive Demo: Scroll to see how indicators work

Mastering React Hooks

Introduction

Getting Started

Advanced Techniques

Best Practices

Conclusion

[data-suchi-indicator="active"]
[data-suchi-indicator="inactive"]
[data-suchi-indicator="inactive"]
[data-suchi-indicator="inactive"]
[data-suchi-indicator="inactive"]

The active indicator takes the --suchi-accentColor CSS Variable while the inactive indicators take the --suchi-inactive-indicator CSS Variable.


Sample styling

For example, lets add variable thickness to the indicators.

[data-suchi-indicator="active"] {
  height: 5px !important;
}
 
[data-suchi-indicator="inactive"] {
  height: 2px !important;
}

Index and Index Items

There are two types of Index - MobileIndex and DesktopIndex. Only one of these Index are rendered based on the toggleWidth prop passed to the Root. See more details here.

Desktop Index

All items in the desktop index are wrapped inside a <div> element that can be targeted using the attributes [data-suchi-desktop-items].

Each item in a <button> element that can be targeted using the attributes [data-suchi-desktop-item].

The item corresponding to the section currently in view will have an "active" state: [data-suchi-desktop-item="active"]. All other items will default to the "inactive" state: [data-suchi-desktop-item="inactive"].

Interactive Demo: Scroll to see how target attributes change

Mastering React Hooks

Introduction

Getting Started

Advanced Techniques

Best Practices

Conclusion

[data-suchi-desktop-item="active"]
Introduction
[data-suchi-desktop-item="inactive"]
Getting Started
[data-suchi-desktop-item="inactive"]
Advanced Techniques
[data-suchi-desktop-item="inactive"]
Best Practices
[data-suchi-desktop-item="inactive"]
Conclusion

By default, the active item takes the --suchi-accentColor CSS Variable while the inactive items take the --suchi-inactive-item CSS Variable.

Sample Styling

For example, lets add some styles to the active index item.

[data-suchi-desktop-item="active"] {
  background-color: #3f3f46 !important;
}
 
[data-suchi-desktop-item]:focus-visible {
  background-color: #52525b !important;
  outline: none;
}

Mobile Index

The mobile index is wrapped within a <div> element that can be targeted using [data-suchi-mobile]. This element is used to position the mobile index as fixed at the bottom of the screen.

The index items are wrapped in a <div> element that can be targeted using [data-suchi-mobile-items]. Each item in a <button> element that can be targeted using the attributes [data-suchi-mobile-item].

Sample Styling

For example, lets add some styles to the active index item.

[data-suchi-mobile-item="active"] {
  background-color: #3f3f46 !important;
  font-weight: 500;
}

Overlay

The Mobile Index has an overlay above Index Tray to give the idea of depth for the underlying content.

You can target the overlay by using [data-suchi-mobile]::before.

Overlay Image

On this page