Question about Turnstile widget types

Is it possible to choose the Turnstile widget to render from JavaScript or is this configurable only in the Turnstile dashboard?

Thanks in advance!

Yes, its possible to render the widget via JS. Please have a look here: Client-side rendering · Cloudflare Turnstile docs

1 Like

out of interest, where does it say how to choose the widget to render?

ngl, the docs are terrible

Yes, I’m wondering about being able to choose the widget to render via JavaScript. I can’t find that information either.

Ah, it’s data-size. Think you have to be explicitly rendering the widget, so maybe like:

    turnstile.render('#example-container', {        
        sitekey: '<YOUR_SITE_KEY>',       
        data-size: 'compact', 
        callback: function(token) {           
           console.log(`Challenge Success ${token}`);       
         },    
    });

^ I haven’t tried this yet, but I’ll get back to you either way :slight_smile:

Still very disappointed with the documentation, it really is very poor for a large company to be producing what are at best slightly ambiguous docs, especially as their pitch is seemingly “user friendliness”.

1 Like

The widget type (Invisible, Managed, Non-interactive) is configured per widget on the dashboard. We have a page dedicated to Widget types.

1 Like

Why have you marked your answer as the solution?

That page says nothing about how you size the widget, whereas (my now hidden?) answer did.

^ The actual solution twilliams

1 Like

Thanks for posting this!

The information maxime.g provided answered my question. I just didn’t ask the original question very well. :frowning: I was asking if it’s possible to choose the widget type via JavaScript and it’s configured on the dashboard only.

Thanks again for doing the research you did and for posting the code snipet!

Oh my bad, I’d though they had marked it as a solution. My answer was hidden as spam within seconds of their reply.

maxime.g was the one who marked their post as the solution, which I agree with. Still, I appreciate the effort you put into helping me. :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.