I would like to use an inline badge with v3, but there is no documentation on badge position for v3.
-
You mean [here](https://developers.google.com/recaptcha/docs/invisible)? Find `data-badge` on page. – kabanus May 29 '18 at 11:35
-
@kabanus I'm talking about https://developers.google.com/recaptcha/docs/v3, that's the v2 doc. – Still don't know everything May 29 '18 at 11:43
-
Ahh I see. Looks iike they simply didn't write the docs yet - consider using their [discussion](https://groups.google.com/forum/#!forum/recaptcha) group to ask, I'm guessing a DEV could help you more easily. – kabanus May 29 '18 at 11:45
6 Answers
You can make the badge inline in V3 with just Javascript it's just not documented yet.
Set your `render` parameter to `explicit` and add a `onload` parameter for the callback, `onRecaptchaLoadCallback` for example.
<script src="https://www.google.com/recaptcha/api.js?render=explicit&onload=onRecaptchaLoadCallback"></script>
Then set up your callback like so and don't forget to enter the id/DOM node of where you want your badge to go, in this case, the id is inline-badge
.
<script>
function onRecaptchaLoadCallback() {
var clientId = grecaptcha.render('inline-badge', {
'sitekey': '6Ldqyn4UAAAAAN37vF4e1vsebmNYIA9UVXZ_RfSp',
'badge': 'inline',
'size': 'invisible'
});
grecaptcha.ready(function() {
grecaptcha.execute(clientId, {
action: 'action_name'
})
.then(function(token) {
// Verify the token on the server.
});
});
}
</script>
Note:
Valid values for 'badge'
are 'inline'
, 'bottomleft'
, 'bottomright'
, and 'bottom'
.
'bottom'
and 'bottomright'
are synonyms.

- 1,190
- 1
- 17
- 18
-
Now documented (to an extent) [in the FAQ](https://developers.google.com/recaptcha/docs/faq#can-i-customize-the-recaptcha-widget-or-badge) and [in the docs for the JS API](https://developers.google.com/recaptcha/docs/invisible#js_api). – Fabien Snauwaert Feb 16 '22 at 16:55
-
1Without the need for a custom callback, just include the JavaScript like so: `` (kudos to [this answer](https://stackoverflow.com/a/68925399/1717535) on another thread.) – Fabien Snauwaert Feb 16 '22 at 17:12
-
Note that to use `'badge': 'inline'` you MUST use `'size': 'invisible'`. But honestly, inline is so ugly because of its size and color that you're better off sticking with the default fixed design. – Fabien Snauwaert May 24 '23 at 17:19
I just have changed the CSS for the grecaptcha-badge class like this:
.grecaptcha-badge {
bottom:25px !important;
}

- 2,450
- 3
- 24
- 48
you can include this into your sass or css to align at left and keep the hover feature active.
.grecaptcha-badge {
width: 70px !important;
overflow: hidden !important;
transition: all 0.3s ease !important;
left: 4px !important;
}
.grecaptcha-badge:hover {
width: 256px !important;
}

- 301
- 2
- 4
EDIT1: See the answer using the render=explicit
parameters. This answer still works but it was before this feature was documented and not as clean.
I've managed to do just that by placing a relative box and detaching the reCaptcha v3 badge into it. Then some style adjustments are made to the container.
#grecaptcha-box {
width: 260px;
overflow: hidden;
position: relative;
height: 75px;
}
#grecaptcha-box .grecaptcha-badge {
box-shadow: none !important;
}
Then you place the box followed by your JavaScript.
<form>
<!-- Rest of your form here... -->
<input type="hidden" id="recaptcha-token" name="recaptcha-token">
<input type="hidden" id="recaptcha-action" name="recaptcha-action">
</form>
<div id="grecaptcha-box"></div>
<!-- Recaptcha v3 -->
<script src="https://www.google.com/recaptcha/api.js?render=xxxxxxxxxxxxxxxxxxxxxxxxxxxx"></script>
<script id="js-recaptcha-init">
const RECAPTCHA_PUBLIC_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
grecaptcha.ready(function() {
// Remove badge from fixed place
var gb = document.getElementsByClassName("grecaptcha-badge")[0];
gb.style.position = 'absolute';
document.getElementById('grecaptcha-box').appendChild(gb.cloneNode(true));
gb.parentNode.removeChild(gb);
// Do the normal recaptcha things...
var grecaptcha_opts = {'action' : 'custom_action'};
grecaptcha.execute(RECAPTCHA_PUBLIC_KEY, grecaptcha_opts)
.then(function(token) {
document.getElementById('recaptcha-token').value = token;
document.getElementById('recaptcha-action').value = grecaptcha_opts.action;
});
});
</script>

- 51
- 5
After execute, you can move the badge by Javascript. It will fix recaptcha timeout error in firefox and chrome browsers.
grecaptcha.ready(function() {
grecaptcha.execute('sitekey', {actienter code hereon: 'loginpage'}).then(function(token) {
/* Move Google Badge to your Div ID */
jQuery('.grecaptcha-badge').appendTo("#g-badge-newlocation");
});
});

- 358
- 2
- 9
Just set it at the div section
<div vc-recaptcha
badge="bottomleft"
>
</div>

- 21
- 1
-
Where do you set this? What's the vc-recaptcha-badge attribute? – Fabien Snauwaert Feb 16 '22 at 17:08