Skip to content

Access <svg> or <mask> inside <md-radio>? #5529

Answered by asyncLiz
alexmeier-19 asked this question in Q&A
Discussion options

You must be logged in to vote

It's unlikely. The two concentric circles are considered an icon together, not a separate element like checkbox's icon vs its outline.

A backdoor option is to use Element.shadowRoot to access the internals of the radio to make changes. This is risky since future updates may break your patch (for example, we could swap from <svg> and <mask> to a CSS-styled <div>).

However, if you don't update often or are willing to take the risk of being broken, it's an option!

const radio = document.querySelector('md-radio');
// Change mask radius to make a thinner outline
radio.shadowRoot.querySelector('mask circle').setAttribute('r', '9');

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@alexmeier-19
Comment options

@asyncLiz
Comment options

Answer selected by alexmeier-19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants