Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom CSS for scan box #449

Closed
jahnavi310 opened this issue Mar 23, 2022 · 4 comments
Closed

Custom CSS for scan box #449

jahnavi310 opened this issue Mar 23, 2022 · 4 comments

Comments

@jahnavi310
Copy link

Hi there,

I am using the pro mode to get a custom overlay for the qr code scanner. I am running into issues on trying to override the CSS for the scan box.

I am for some reason not able to style the qr-shaded-region div, is there a way i can override the CSS for the scan box with something custom?

Thanks in advance

@YTKowshik
Copy link

@jahnavi310 take a look at the issue #429. It may help you.

@sarukomine
Copy link

You can remove them and add your own element with custom class into the scan box element.

qrScanner.start(......).then(() => {
    let overlayElement = document.getElementById('qr-shaded-region');
    let childElements = overlayElement.querySelectorAll('div');

    // Remove corners
    for (let childElement of childElements) {
        childElement.remove();
    }

    // Create own corner elements
    let leftTopElement = document.createElement('div');
    let leftBottomElement = document.createElement('div');
    let rightTopElement = document.createElement('div');
    let rightBottomElement = document.createElement('div');

    leftTopElement.classList.add('custom-corners-css');
    leftBottomElement.classList.add('custom-corners-css');
    rightTopElement.classList.add('custom-corners-css');
    rightBottomElement.classList.add('custom-corners-css');

    overlayElement.appendChild(leftTopElement);
    overlayElement.appendChild(leftBottomElement);
    overlayElement.appendChild(rightTopElement);
    overlayElement.appendChild(rightBottomElement);
});

@mebjas
Copy link
Owner

mebjas commented Oct 29, 2022

Marking this as a duplicate of #389

Let's have more discussion there.

@mebjas mebjas closed this as completed Oct 29, 2022
@fyrus7
Copy link

fyrus7 commented Oct 11, 2024

You can remove them and add your own element with custom class into the scan box element.

qrScanner.start(......).then(() => {
    let overlayElement = document.getElementById('qr-shaded-region');
    let childElements = overlayElement.querySelectorAll('div');

    // Remove corners
    for (let childElement of childElements) {
        childElement.remove();
    }

    // Create own corner elements
    let leftTopElement = document.createElement('div');
    let leftBottomElement = document.createElement('div');
    let rightTopElement = document.createElement('div');
    let rightBottomElement = document.createElement('div');

    leftTopElement.classList.add('custom-corners-css');
    leftBottomElement.classList.add('custom-corners-css');
    rightTopElement.classList.add('custom-corners-css');
    rightBottomElement.classList.add('custom-corners-css');

    overlayElement.appendChild(leftTopElement);
    overlayElement.appendChild(leftBottomElement);
    overlayElement.appendChild(rightTopElement);
    overlayElement.appendChild(rightBottomElement);
});

Anyone got an idea how to do this? I cant shape the shade region

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants