🌐 AI搜索 & 代理 主页
Skip to content

Best way to apply data-bs-theme="dark" to an inner element (e.g. offcanvas-header) #2828

@VividLemon

Description

@VividLemon

Discussed in #2827

Originally posted by hackel September 2, 2025
I'm trying to implement a design with a dark background for an Offcanvas header, and need to change the color of the close button. As far as I can tell adding data-bs-theme="dark" is the correct way to do this, but I can't figure out a way to add it other than recreating the entire header section, which seems wrong. I thought it was worth a discussion and maybe worth considering a new prop for the Offcanvas component (and other related components like Modal).

I had no luck trying to change the color by applying a custom class with header-close-class, and header-close-variant seems to have no effect whatsoever. I looked at useColorMode, but I don't see any way to get a template ref to the inner header element. It seems like adding a header-dark prop that just adds data-bs-theme="dark" to the offcanvas-header element might make the most sense. Thoughts? Maybe I'm missing something. Thanks.

https://github.com/bootstrap-vue-next/bootstrap-vue-next/blob/26dd7e2cf9495771d51998ebfbfee8805a1fbcf9/packages/bootstrap-vue-next/src/components/BOffcanvas/BOffcanvas.vue#L28C72-L28C89

Add a prop for headerAttrs as is the standard and have it apply to this element. That way one can bind v-bind={'data-bs-theme': 'dark'} manually, or an id to target for a selector for useColorMode or something

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions