getModuleClass()function

getModuleClass(module: CSSModule | string, ...classes: unknown[]): string | undefined
ParamType
moduleCSSModule
string
CSS module object or a string.
- Allows "string" because if this environment does not process *.module.css files then import styles from "./styles.module.css" will be a string.
- This allows this situation to be handled gracefully and classes will be silently ignored in this environment. required
classesunknown[]
Class keys/values to merge. required
Return
string | undefined
The merged string classname, or undefined when module is a string (unprocessed CSS module).

Parse a list of possible className strings, match them in a CSSModule dictionary, and join them into a single string.

  • See Classes type for parsing rules.

Examples

getModuleClass(styles, "base", { active: true }) // "base_x7q active_p2k"